//
//  YKOrderDetailItemCell.m
//  YunKang
//
//  Created by leoking870 on 2017/10/3.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKOrderDetailItemCell.h"
#import <UIImageView+WebCache.h>

@interface YKOrderDetailItemCell ()
/**
 图片
 */
@property (weak, nonatomic) IBOutlet UIImageView *FACE_PIC1;
/**
 商品名称
 */
@property (weak, nonatomic) IBOutlet UILabel *CINV_NAME;
/**
 单价
 */
@property (weak, nonatomic) IBOutlet UILabel *CINV_PRICE;
/**
 数量
 */
@property (weak, nonatomic) IBOutlet UILabel *CINV_NUM;
/**
 规格
 */
@property (weak, nonatomic) IBOutlet UILabel *CPACKINGTYPE;
@property (weak, nonatomic) IBOutlet UILabel *CENTERPRISE;

@end


@implementation YKOrderDetailItemCell
@dynamic tableViewItem;

- (void)cellLoadSubViews {
    [super cellLoadSubViews];
}

- (void)cellWillAppear{
    [super cellWillAppear];
    [self.FACE_PIC1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://yunkangmall.njnwyy.com:8084%@",self.tableViewItem.model.FACE_PIC1]] placeholderImage:[UIImage imageNamed:@"yk_order_item_img"]];
    self.CINV_NAME.text = self.tableViewItem.model.GENERIC_NAME;
    self.CINV_PRICE.text = [NSString stringWithFormat:@"¥%@", self.tableViewItem.model.CINV_PRICE];
    
    self.CPACKINGTYPE.text = [NSString stringWithFormat:@"规格：%@", self.tableViewItem.model.CPACKINGTYPE];
    
    if ([self.tableViewItem.istatus isEqualToString:@"9"]) {
        //退货
        NSString *text = [NSString stringWithFormat:@"申请:%@",self.tableViewItem.model.CINV_NUM];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:5];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
        self.CINV_NUM.attributedText = attributedString;
        
    }
    else if ([self.tableViewItem.istatus isEqualToString:@"10"]){
        //退货
        NSString *text = [NSString stringWithFormat:@"申请:%@\n收货:%@\n拒收:%@",self.tableViewItem.model.CINV_NUM,self.tableViewItem.model.COLLECTNUM,self.tableViewItem.model.REJECTIONNUM?:@""];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:5];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
        self.CINV_NUM.attributedText = attributedString;
    }
    else {
        NSString *text = [NSString stringWithFormat:@"下单:%@\n确认:%@\n调整:%@",self.tableViewItem.model.QUANTITY,self.tableViewItem.model.CINV_NUM?:@"",self.tableViewItem.model.EDT_NUM?:@""];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:8];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
        self.CINV_NUM.attributedText = attributedString;
    }
    self.CENTERPRISE.text = self.tableViewItem.model.CENTERPRISE;
}

@end
